<?php
$loader->requireOnce('ordo/TicketItem.class.php');
$loader->requireOnce('includes/ServiceDiscount/ServiceItemPayment.class.php');
$loader->requireOnce('includes/ServiceDiscount/TestItemPayment.class.php');
$loader->requireOnce('includes/ServiceDiscount/CompositeServiceItemPayment.class.php');
$loader->requireOnce('includes/ServiceDiscount/ServiceDiscountException.class.php');

class TicketItemPaymentFactory {		
	
	/**
	 * Factory method to instance a TicketItem based on its type
	 *
	 * @param String $type
	 * @throws ServiceDiscountException if
	 *   $type is not supported
	 * @return TicketItemPayment
	 */
	public static function createItemPayment($ticketItemType, $discountBehaviour) {
		switch ($ticketItemType) {
			case TicketItem::SERVICE_TYPE:
				return new ServiceItemPayment($discountBehaviour);				
			case TicketItem::TEST_TYPE:
				return new TestItemPayment($discountBehaviour);
			case TicketItem::COMPOSITE_SERVICE:
				return new CompositeServiceItemPayment($discountBehaviour);							
			default:
				throw new ServiceDiscountException("Ticket item type <$ticketItemType> is not supported");			
		}
		
	}
}
?>